﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Invoicing.Pubs
{
    public class AjaxHandle
    {
        /// <summary>
        /// 返回代码，300错误 200成功外加信息 , statusCode 缩写 as   message 缩写meg
        /// </summary>
        /// <returns></returns>
        public static string AjaxPress(string statusCode, string Mesage)
        {
            return "{\"as\":\"" + statusCode + "\", \"meg\":\"" + Mesage + "\"}";
        }


        /// <summary>
        /// 已  NavtabI 返回状态 错误300， 成功200  
        /// </summary>
        /// <param name="statusCode">返回状态</param>
        /// <param name="Message">提示信息</param>
        /// <param name="navTabid">Navtabid</param>
        /// <returns></returns>
        public static string AjaxPress(string statusCode, string Message, string navTabid,string furl)
        {
     
                return "{\"statusCode\":\"" + statusCode + "\", \"message\":\"" + Message + "\", \"navTabId\":\"" + navTabid + "\", \"forwardUrl\":\""+furl+"\", \"callbackType\":\"closeCurrent\"}";

        }


        /// <summary>
        /// ajaxTodo 方式回传的信息
        /// </summary>
        /// <returns></returns>
        public static string AjaxPressTodo(string statusCode, string Message)
        {

            return "{\"statusCode\":\"" + statusCode + "\",\"message\":\"" + Message + "\",\"navTabId\":\"\",\"forwardUrl\":\"\"}";
                    
        }


        /// <summary>
        /// 回复成功的json {"statusCode":"200", "message":"操作成功!"}"
        /// </summary>
        /// <returns></returns>
        public static string Success()
        {
            return "{\"as\":\"200\", \"message\":\"操作成功!\"}";
        }
        /// <summary>
        /// 回复成功的json,并刷新名称为navTabId的Tab
        /// </summary>
        /// <param name="str">{"statusCode":"200", "message":"操作成功!{str的内容}"}"</param>
        /// <param name="navTabId">navTabId的名称</param>
        /// <returns></returns>
        public static string Success(string str, string navTabId)
        {
            return "{\"as\":\"200\", \"meg\":\"操作成功!" + str + "\",\"navTabId\":\"" + navTabId + "\"}";
        }
        /// <summary>
        /// 失败的json {"statusCode":"300", "message":"操作失败!"}"
        /// </summary>
        /// <returns></returns>
        public static string failure()
        {
            return "{\"as\":\"300\", \"meg\":\"操作失败\"}";
        }
        /// <summary>
        /// 失败的json {"statusCode":"300", "message":"操作失败!{str的内容}"}"
        /// </summary>
        /// <param name="str">{"statusCode":"300", "message":"操作失败!{str的内容}"}"</param>
        /// <returns></returns>
        public static string failure(string str)
        {
            return "{\"statusCode\":\"300\", \"message\":\"操作失败!" + str + "\"}";
        }





    }
}